<template>
	<view>
		<view class="card">
			<image src="https://mp-e3fbd118-dad0-4878-b40b-44597e7aa0eb.cdn.bspapp.com/icons/星星.png" class="head-img" mode="widthFix"></image>
			<view class="msg msg-top">
				再接再厉
			</view>
			<view class="msg msg-center">
				测试得分：{{score}}
			</view>
			<button  open-type="share" >打卡分享</button>
			<button  type="default" @click="openScore" v-show="id">查看结果</button>
		</view>
	</view>
</template>

<script>
	const pageDataCenter=uniCloud.importObject('page-data-center')
	export default {
		data() {
			return {
				score:'',
				type:0,
				id:"",
				share: {
					
				}
			}
		},
		onLoad(e) {
			this.score=e.score
			this.id=e.id
			this.type=e.type || 0
			this.getData()
		},
		methods: {
			getData(){
				pageDataCenter.getShareContent().then((res)=>{
					console.log(res)
					this.share=res.data
				})
			},
			openScore(){
				uni.navigateTo({
					url:`./score?id=${this.id}&type=${this.type}`
				})
			}
		},
		onShareAppMessage(res) {
				//实现根据不同页面返回不同的转发信息
				let pages = getCurrentPages();
				let routerUrl = pages[0].route //获取当前页的路径
				return {
					title: this.share.title,
					path: '/' + routerUrl, // 路径前面必须要加'/'
					imageUrl: this.share.imageUrl,
					desc: this.share.desc,
					content: this.share.content,
					success(res) {
						uni.showToast({
							title: '分享成功'
						})
					},
					fail(res) {
						uni.showToast({
							title: '分享失败',
							icon: 'none'
						})
					}
				}
			}
	}
</script>

<style scoped>
	.card{
		padding: 20px;
		text-align: center;
		background-color: #fff;
		font-size: 16px;
		margin: 40px auto;
		border: 1px solid #eee;
		border-radius: 8px;
		width: 90%;
	}
	.head-img{
		width: 150px;
	}
	.msg{
		margin: 10px 0;
	}
	.msg-top{
		color: #000;
		font-weight: 700;
		font-size: 28px;
	}
	button{
		width:200px;
		height:40px;
		line-height:40px;
		color:#fff;
		background:#32a550;
		fontWeight:700;
		border:none;
		font-size:20px;
		margin-top: 15px;
	}
</style>
